<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
</head>
<body>
<div class="layui-form tentime-compile">
    <form id="inputForm" class="layui-form">
        <input th:each="id:${idList}" type="hidden" name="ids" th:value="${id}"/>
        <div class="layui-form-item">
            <label class="layui-form-label required">新密码</label>
            <div class="layui-input-inline">
                <input class="layui-input" lay-verify="required" type="password" name="password" placeholder="请输入新密码">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">确认密码</label>
            <div class="layui-input-inline">
                <input class="layui-input" lay-verify="required|confirmPass" type="password" name="confirm" placeholder="再一次输入密码">
            </div>
        </div>
        <div class="layui-form-item tentime-finally">
            <button class="layui-btn layui-btn-sm layui-btn-primary" lay-submit lay-filter="submit_button" shiro:hasAnyPermissions="system:user:pwd"><i class="fa fa-check-circle"></i> 保存</button>
            <button class="layui-btn layui-btn-sm layui-btn-primary" onclick="closeWin();" type="button"><i class="fa fa-times-circle"></i> 关闭</button>
        </div>
    </form>
</div>
<script th:replace="/common/template :: common"></script>
<script type="text/javascript">
    layui.use(['form'], function () {
        window.form = layui.form;
        form.verify({
            confirmPass:function(value){
                if($('input[name=password]').val() !== value) {
                    return '两次密码输入不一致！';
                }
            }
        });
        form.on("submit(submit_button)", function (data) {
        	$("#inputForm").ajaxSubmit({
				type : "post"
	            ,url : ctx + '/system/user/resetPass'
	            ,success : function(data) {
	            	var code = data.code;
	            	var msg = data.msg;
	            	if (code == 200) {
	            		parent.layer.msg(msg, {icon: 1});
	            		closeWin();
	            	} else {
	            		parent.layer.msg('数据验证失败：' + msg, {icon: 2});
	            	}
	            }
			});
       		return false;
       	});
    });
</script>
</body>
</html>